<?php
// +--------------------------------------------------------------------------
// | ZAIYOUDAO [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:17090888854>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * 我的信息
 */
namespace Research\Controller;
use Common\Controller\AdminController;

/**
 * 我的控制器
 */
class MyController extends AdminController{
	
	/**
	 * 修改信息
	 */
    public function Info(){

		common_public()->assign_page('修改信息');
		
		$m_common_user = M('common_user');
			
		$map['id'] = getUID();
			
		if(IS_AJAX){
			
			action_log('admin_my_info_edit');//行为记录
		
			$data = I('');
			
			$result = $m_common_user->where($map)->save($data);
	
			//返回信息
			$info = $result?get_errcode(0):get_errcode(10000002);
			
			$this->ajaxReturn($info);
			
		}else{
			
			action_log('admin_my_info_view');//行为记录
		
			$data = $m_common_user->where($map)->find();
			
			$this->assign('data',$data);
			
			$this->display();
		}
		
		
	}
	
	/**
	 * 修改密码
	 */
    public function Password(){
		
		common_public()->assign_page('修改密码');
		
		$m_common_user = M('common_user');
			
		$map['id'] = getUID();
		
		if(IS_AJAX){
			
			action_log('admin_my_password_edit');//行为记录
		
			$map['password'] = md5(I('param.oldpassword'));
			$data['password'] = md5(I('param.password'));
			
			$result = $m_common_user->where($map)->save($data);
	
			//返回信息
			$info = $result?get_errcode(0):get_errcode(10000003);
			
			$this->ajaxReturn($info);
			
		}else{
			
			action_log('admin_my_password_view');//行为记录
		
			$this->display();
		}
	}
	
	
}